<template>
  <div>
      <div>
    <el-form
      ref="form"
      :model="form"
      :inline="true"
      label-position="right "
      label-width="100px"
    >
      <el-form-item label="规则名称" >
        <el-input v-model="form.rname" ></el-input>
      </el-form-item>


      <el-form-item label="开始时间">
            <div class="block">
              <el-date-picker
                v-model="form.starttime"
                value-format="yyyy-MM-dd"
                type="date"
                placeholder="开始时间"
              ></el-date-picker>
            </div>
      </el-form-item>

      <el-form-item label="到期时间">
            <div class="block">
              <el-date-picker
                v-model="form.expires"
                value-format="yyyy-MM-dd"
                type="date"
                placeholder="到期时间"
              ></el-date-picker>
            </div>
      </el-form-item>
      

      <el-form-item label="上线/下线">
        <el-input v-model="form.status"></el-input>
      </el-form-item>

      <el-form-item label="命中次数">
        <el-input v-model="form.hits"></el-input>
      </el-form-item>

    <el-form-item>
        <el-button type="primary" @click="onSubmit">确定</el-button>
        <el-button>取消</el-button>
      </el-form-item>
      </el-form>
  </div>
  
  </div>
</template>

<script>
export default {
  data() {
    return {
        tableData: [],
        tableData1: [],
      form: {
        rname: "",
        starttime:"",
        expires:"",
        hits:"",
        status:"",
      },
     
      rate: {
          issue: "",
          monthrate: ""
      }
    };
  },
  created(){
// this.getRepaymentAll();
// this.getEnablestatusAll();
},
  methods: {
//查询还款方式表单中的所有信息 名称展示到下拉框
getRepaymentAll(){
        this.$axios.get("http://localhost:8601/products/allRepayment").then(resp=>{
          this.tableData=resp.data;
          console.log(resp);
        });
},

//查询启用状态表单中的所有信息 名称展示到下拉框
getEnablestatusAll(){
        this.$axios.get("http://localhost:8601/products/all").then(resp=>{
          this.tableData1=resp.data;
          console.log(resp);
        });
},

    onSubmit() {
      console.log("submit!");
      //点击提交将数据传递到后端 添加数据
            this.$axios
        .post("http://192.168.12.166:8601/rules/add", this.form)
        .then((resp) => {
          console.log(resp);
        });
      console.log("submit!");
      this.$message({
        message: "添加成功",
        type: "success",
      });
      
    }


  },
};
</script>

<style>
#aaa{
  height: 200px;
}

div{margin: 0ex; padding: 0ex;}.con{float: left;}
</style>